﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="SearchNewVolunteer.ascx.vb"
    Inherits="WebForm_ApproveVolunteer_SearchNewVolunteer" %>
<%@ Register Namespace="My" TagPrefix="cc1" %>
<table>
    <tr>
        <td align="right">
            <asp:Label ID="lblDataSource" runat="server" meta:resourcekey="lblDataSource"></asp:Label>
        </td>
        <td align="left">
            <asp:DropDownList ID="ddlDataSource" runat="server" AutoPostBack="true" Enabled="false">
            </asp:DropDownList>
        </td>
    </tr>
    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="1">
        <asp:View ID="EnlistHeaderView" runat="server">
            <tr>
                <td align="right">
                    <asp:Label ID="lblEnlistHeader" runat="server" meta:resourcekey="lblEnlistHeader"></asp:Label>
                </td>
                <td align="left">
                    <asp:DropDownList ID="ddlEnlistHeader" runat="server" AutoPostBack="false">
                    </asp:DropDownList>
                </td>
            </tr>
        </asp:View>    
        <asp:View ID="OrganizationView" runat="server">
            <tr>
                <td align="right">
                    <asp:Label ID="lblOrganization" runat="server" meta:resourcekey="lblOrganization"></asp:Label>
                </td>
                <td align="left">
                    <asp:DropDownList ID="ddlOrganization" runat="server" AutoPostBack="false">
                    </asp:DropDownList>
                </td>
            </tr>
        </asp:View>        
    </asp:MultiView><tr>
        <td align="right">
            <asp:Label ID="lblStatus" runat="server" meta:resourcekey="lblStatus"></asp:Label>
        </td>
        <td align="left">
            <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="false">
            </asp:DropDownList>
        </td>
        <td align="left">
            <asp:Button ID="btnQuery" runat="server" meta:resourcekey="btnQuery" />
        </td>
    </tr>
</table>
<br />
<asp:MultiView ID="MultiView2" runat="server" ActiveViewIndex="0">
        <asp:View ID="OrganizationGridView" runat="server">
<My:MyGridView ID="gv" runat="server" SkinID="pager" AllowHoverSelect="True" DataKeyNames="ApplicationID"
    meta:resourcekey="gv" AllowHoverEffect="True" AutoGenerateColumns="False" MySortDirection="Ascending">
    <Columns>
        <asp:TemplateField HeaderText="<%$ Resources:TownName %>">
            <ItemTemplate>
                <%#Eval("TownName") %><%#Eval("RegionName")%>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
        <asp:BoundField DataField="VolunteerID" meta:resourcekey="bfVolunteerID" />
        <asp:BoundField DataField="VolunteerName" meta:resourcekey="bfVolunteerName" />
        <asp:BoundField DataField="OrganizationName" meta:resourcekey="bfOrganizationName" />
        <asp:TemplateField>
            <HeaderTemplate>
                <asp:Label ID="bfApplyDate" runat="server"></asp:Label>
            </HeaderTemplate>
            <ItemTemplate>
                <%#Eval("ApplyDate") %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Approver" meta:resourcekey="bfApprover" />
    </Columns>
</My:MyGridView>
        </asp:View>    
        <asp:View ID="EnlistHeaderGridView" runat="server">
 <My:MyGridView ID="gv2" runat="server" DataSourceID="SqlDataSource1" SkinID="pager" AllowHoverSelect="True" DataKeyNames="ApplicationID"
    meta:resourcekey="gv2" AllowHoverEffect="True" MySortDirection="Ascending" AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField HeaderText="<%$ Resources:TownName %>">
            <ItemTemplate>
                <%#Eval("TownName") %><%#Eval("RegionName")%>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>    
        <asp:BoundField DataField="VolunteerID" meta:resourcekey="bfVolunteerID"  SortExpression="VolunteerID" />
        <asp:BoundField DataField="VolunteerName" meta:resourcekey="bfVolunteerName"  SortExpression="VolunteerName" />
        <asp:TemplateField>
            <HeaderTemplate>
                <asp:Label ID="bfCreateDate" runat="server"></asp:Label>
            </HeaderTemplate>
            <ItemTemplate>
            <asp:Label id="lblVOrganizationID" runat="server" Text='<%# Bind("VOrganizationID") %>' Visible="false"></asp:Label>
<asp:Label id="Label1" runat="server" Text='<%# Bind("CreateDate", "{0:yyyy/MM/dd}") %>'></asp:Label><asp:Label id="lblEnlist" runat="server" Text='<%# Bind("EnlistID") %>' Visible="false"></asp:Label>
                
            </ItemTemplate>
        </asp:TemplateField>
        
<%--        <asp:TemplateField SortExpression="CreateDate"  meta:resourcekey="bfCreateDate">
            <edititemtemplate>
<asp:TextBox runat="server" Text='<%# Bind("CreateDate") %>' id="TextBox2"></asp:TextBox>
</edititemtemplate>
            <itemtemplate>
            <asp:Label id="lblVOrganizationID" runat="server" Text='<%# Bind("VOrganizationID") %>' Visible="false"></asp:Label>
<asp:Label id="Label1" runat="server" Text='<%# Bind("CreateDate", "{0:yyyy/MM/dd}") %>' __designer:wfdid="w2"></asp:Label><asp:Label id="lblEnlist" runat="server" Text='<%# Bind("EnlistID") %>' Visible="false" __designer:wfdid="w1"></asp:Label>
</itemtemplate>
        </asp:TemplateField>
--%>        <asp:BoundField DataField="Approver" meta:resourcekey="bfApprover" />
    </Columns>
</My:MyGridView>    
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>" SelectCommand="select a.ApplicationID,a.EnlistID,a.VolunteerID,a.VOrganizationID
    ,r.TownName, r.RegionName 
    , case when a.Status = 'WA' then a.CreateDate else c.ApproveDate end as CreateDate ,b.VolunteerName,Case a.Status when 'WA' then '' else u.UserName + ' ' + o.OrganizationName end as Approver from EnlistRecordApplication a&#13;&#10;Join Volunteer b on a.VolunteerID=b.VolunteerID&#13;&#10; left join ApproveRecord c on a.ApplicationID = c.FormID 
    left join InternalUser u on c.approver = u.userid
    left join OrganizationView o on u.UOrganizationID = o.UOrganizationID
    inner join Village r on b.VillageID = r.RegionID
    where a.EnlistID=@EnlistID&#13;&#10;and a.Status=@Status order by a.Createdate desc">
    <SelectParameters>
        <asp:Parameter Name="EnlistID" />
        <asp:ControlParameter ControlID="ddlStatus" Name="Status" PropertyName="SelectedValue" />
    </SelectParameters>
</asp:SqlDataSource>   
        </asp:View> 
</asp:MultiView>
